#pragma once
#include "AbstractGraph.h"
#include <vector>
#include <algorithm>
#include <utility>


namespace{
	class MatrixGraph : public Graph{
	std::vector<std::vector<bool> > matrix_;
	public:
		MatrixGraph(int vertexNum, const std::vector<Edge>& edgesList){
			setVertexNum(vertexNum);
			matrix_.assign(getVertexNum(), std::vector<bool>(getVertexNum(), 0));
			for (size_t currentEdge = 0; currentEdge < edgesList.size(); ++currentEdge){
				setEdge(edgesList[currentEdge].fromVertex, edgesList[currentEdge].toVertex);
			}
		}
		const bool getEdge(int fromVertex, int toVertex) const {
			return matrix_[fromVertex][toVertex];
		}
		void setEdge(int fromVertex, int toVertex){
			matrix_[fromVertex][toVertex] = true;
		}
		
		const std::vector<int> getAdjacentList(int inputVertex) const {
			std::vector<int> adjacentList;
			for (int currentVertex = 0; currentVertex < getVertexNum(); ++currentVertex){
				if (getEdge(inputVertex, currentVertex)){
					adjacentList.push_back(currentVertex);
				}
			}
			return adjacentList;
		}
		
	};

}

